import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class HomeGridCard extends StatelessWidget {
  Widget _buildCardHead(title) {
    return Container(
      width: 680.w,
      height: 90.w,
      alignment: Alignment.centerLeft,
      child: Text(
        title,
        style: TextStyle(
            color: Color(0xFF333333),
            fontSize: 16,
            fontWeight: FontWeight.bold),
      ),
    );
  }

  Widget _buildGrid(context) {
    List<Widget> tiles = [];
    Widget content;

    List formList = [
      {"title": '新建入库', "icon": 'assets/hc_10.png', "route": '/new_enter'},
      {"title": '物资入库', "icon": 'assets/hc_1.png', "route": '/enter'},
      {"title": '物资出库', "icon": 'assets/hc_2.png', "route": '/out_page'},
      {"title": '物资盘点', "icon": 'assets/hc_3.png', "route": '/check'},
      {"title": 'RFID扫描', "icon": 'assets/hc_11.png', "route": '/rfid_scan'},
      {"title": '待办任务', "icon": 'assets/hc_4.png', "route": '/task'},
      {"title": '数据分析', "icon": 'assets/hc_5.png', "route": '/data_analysis'},
      {"title": '个人中心', "icon": 'assets/hc_6.png', "route": '/personal_center'},
      {"title": '物资管理', "icon": 'assets/hc_7.png', "route": '/manage'},
      {"title": '历史记录', "icon": 'assets/hc_8.png', "route": '/history'},
      {"title": '数据统计', "icon": 'assets/hc_9.png', "route": '/data_statistics'},
      {"title": '报废入库', "icon": 'assets/sc_icon.png', "route": '/scrap_enter'},
      {
        "title": '设备更换入库',
        "icon": 'assets/hc_1.png',
        "route": '/allocate_enter'
      },
      // {
      //   "title": '证物入库',
      //   "icon": 'assets/hc_1.png',
      //   "route": ''
      // },
    ];

    formList.forEach((e) {
      tiles.add(Material(
        color: Colors.white,
        child: new Ink(
          decoration: new BoxDecoration(
            color: Colors.white,
            border: Border.all(color: Color(0xFFF1F1F1)),
            borderRadius: new BorderRadius.all(new Radius.circular(20.w)),
          ),
          child: new InkWell(
            // highlightColor: Utils.hexToColor('#F2F2F2'),
            onTap: () {
              Navigator.pushNamed(context, e['route']);
            },
            borderRadius: new BorderRadius.circular(20.w),
            child: new Container(
              width: 210.w,
              height: 220.w,
              //设置child 居中
              alignment: Alignment(0, 0),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Image.asset(
                    e['icon'],
                    width: 80.w,
                    height: 80.w,
                  ),
                  Container(
                    margin: EdgeInsets.only(top: 25.w),
                    child: Text(e['title'],
                        style: TextStyle(
                            color: Color(0xFF333333),
                            fontSize: 14,
                            fontWeight: FontWeight.bold)),
                  )
                ],
              ),
            ),
          ),
        ),
      ));
    });

    content = new Wrap(spacing: 20.w, runSpacing: 20.w, children: tiles);
    return content;
  }

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false);

    return Container(
      width: 720.w,
      padding: EdgeInsets.only(bottom: 50.w),
      margin: EdgeInsets.fromLTRB(15.w, 677.w, 15.w, 0.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(20.w),
      ),
      child: Column(
        children: <Widget>[
          _buildCardHead('功能展示'),
          _buildGrid(context),
        ],
      ),
    );
  }
}
